using UnityEngine;
public enum RoomType
{
    None, Exit
}
public class Room : MonoBehaviour
{
    /// <summary>
    /// 房间的坐标
    /// </summary>
    public Vector2 Coordinate;
    /// <summary>
    /// 生成迷宫砸墙时，已经到达该房间
    /// </summary>
    public bool IsInit;
    /// <summary>
    /// 周围是否有没有初始化的房间
    /// </summary>
    /// <returns></returns>
    public bool NearUnInitRoom()
    {
        if ((Coordinate.y < InitMaze.Instance.BuildColumn - 1 && !(InitMaze.Instance.RoomDict[(Coordinate + Vector2.up).ToString()].IsInit)) ||
        (Coordinate.y > 0 && !(InitMaze.Instance.RoomDict[(Coordinate + Vector2.down).ToString()].IsInit)) ||
        (Coordinate.x > 0 && !(InitMaze.Instance.RoomDict[(Coordinate + Vector2.left).ToString()].IsInit)) ||
        (Coordinate.x < InitMaze.Instance.BuildRow - 1 && !(InitMaze.Instance.RoomDict[(Coordinate + Vector2.right).ToString()].IsInit)))
        {
            return true;
        }
        return false;
    }
    private void Start()
    {
        // 把右下角最后一个房间设置为通关房间
        if (Coordinate.x == InitMaze.Instance.BuildRow - 1 && Coordinate.y == InitMaze.Instance.BuildColumn - 1)
        {
            transform.GetChild(0).GetComponent<Reward>().RewardType = RoomType.Exit;
            // 打开房间中央的碰撞体
            transform.GetChild(0).gameObject.SetActive(true);
        }
    }
}
